<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/pub/head_latest.inc"%>
<script src="${baseURL}/js/zeroclipboard/ZeroClipboard.js"
	type="text/javascript">
	</script>
<script type="text/javascript">
</script>
<title>商品首页</title>
</head>
<body>
	<!-- 这里定义了转发进入的TAB对应的菜单ID，也是TAB的属性ID值 -->
  		<input type="hidden" name="menuId" id="menuId" value="${param.menuId}"/>
  		<!-- 搜索表单 -->
  		<!-- <div id="mainsearch" style=" width:98%">
    		<div class="searchbox"> -->
	        	<form id="formsearch" class="l-form" method="get">
			        <table cellpadding="0" cellspacing="1" class="l-table-edit" >
			            <tr>
			                <td align="right" class="l-table-edit-td">商品名</td>
			                <td align="left" class="l-table-edit-td" >
								<input type="text" id="name" name="name" ltype="text" class="field" value="" style="margin-left: 2px;width: 160px"/>
			                </td>
			                <td align="left" class="l-table-edit-td" style="padding-left: 30px">
								<input type="button" value="搜索" id="btnSearch"  class="l-button l-button-submit"  /> 
			                </td>
			                <td align="left" class="l-table-edit-td">
								<input type="reset" value="重置" id="btnReset" class="l-button l-button-test"/> 
			                </td>
			            </tr>
			        </table>
	       		</form>
		<!-- 	</div>
  		</div> -->
	<!-- 表格列表 -->
		<div id="maingrid"></div> 
  		<script type="text/javascript">
	      	//列表结构
	      	var grid = $("#maingrid").ligerGrid({ 
		        columns: [
					{display:"商品名",name:"name",width:300,type:"text",align:"center",isSort : true},
					{display:"价格",name:"price",width:200,type:"text",align:"center",isSort : true},
					{display:"描述",name:"desc",width:150,type:"text",align:"center",isSort : true},
				 	{display:"供应商名字",name:"providerName",width:150,type:"text",align:"center",isSort : true}
			        ],
				dataAction: 'server', 
	          	url: '${baseURL}/moduledemo/fun7/fun7demolist/listJSON.do',
	          	width: '100%', height: '100%',heightDiff:-10, checkbox: false,
	        	pageParmName:"pageNo",pageSizeOptions:[${pageOptions}],pagesizeParmName:"perPageSize",
	          	rowHeight:23,rownumbers:true,isScroll:true, sortnameParmName:"sortName", 
	         	sortorderParmName:"sortOrder", pageSize: ${pageSize} 
	      	});
	
		  	var selectedRow = grid.getCheckedRows();
	       //加载toolbar
	      	/* LG.createToolbarButton(grid, [
	      								{id : "delete", name : "删除", clickEvent : FF_DeletedClickEvent,  icon : "a fa fa-minus-square-o" ,type:"icon"},
	      								{id : "details", name : "商品详情", clickEvent : FF_DetailsClickEvent, icon : "a fa fa-pencil-square-o" ,type:"icon"},
	      								  ]);
	 */
	       
		      	//删除事件
		      	function FF_DeletedClickEvent(btnItem){
		      		var selectedRow = grid.getCheckedRows();
		      		if (!selectedRow || !selectedRow.length) {
		      			alert("请先选择需要删除的行!"); return false;
		      		}
		      		jQuery.ligerDialog.confirm('您确定删除吗?', function (confirm) {
		              	if (confirm){
		              		$.ajax({
			   					type: "GET",
			   					url: "${baseURL}/moduledemo/fun7/fun7demodelete/delete.do",
			   					dataType : "json",
			   					data: "ids="+LG.serialIdParam(selectedRow),
			   					beforeSend: function (){
					                LG.loading = true;
					                LG.showLoading('正在处理中...请稍候');
					            },
					            complete: function (){
					                LG.loading = false;	  
					                LG.hideLoading();
					            },
			   					success: function(msg){
			     					if(msg && msg.hasOk){
		     						 FF_Reload();
		     						 alert('操作成功!');
		     					}else{
		     						alert("操作失败!失败信息如下:\n"+msg.message+"\n如您对以上信息有疑问，请联系管理人员!");
		     					}
		   					}
	 				 	});
	              	}
	        	});
	      	}
		      	
		    	/* //加入购物车事件
		      	function FF_ExportClickEvent(btnItem){
		      		var selectedRow = grid.getCheckedRows();
		      		if (!selectedRow || !selectedRow.length) {
		      			alert("至少选择一件商品!"); return false;
		      		}
		      		parent.f_addTab("购物车", '我的购物车', "${baseURL}/moduledemo1/customer/addGoodsToCart.do?ids="+LG.serialIdParam(selectedRow));
	      	} */
		      //详情事件
		      	function FF_DetailsClickEvent(btnItem){
		      		var selectedRow = grid.getCheckedRows();
		      		if (!selectedRow || selectedRow.length!=1) {
		      			alert("请选择一个商品!"); return false;
		      		}
		      		parent.f_addTab("商品详情", '商品详情', '${baseURL}/moduledemo/fun7/fun7demolist/details.do?goodsId='+LG.serialIdParam(selectedRow));
	      	}
		    	
		      
		       /*  //商品销量走势
		      	function FF_ChartClickEvent(btnItem){
		      		var selectedRow = grid.getCheckedRows();
		      		if (!selectedRow || selectedRow.length!=1) {
		      			alert("请选择一个订单!"); return false;
		      		}
		      		parent.f_addTab("商品七天销量", '销量', 'http://localhost:8080/initail-project/moduledemo1/charts/toGoodsChart.do?goodsId='+LG.serialIdParam(selectedRow));
	      	} */
		        
	      	$("#formsearch").ligerForm();
		  	//搜索事件
	      	$("#btnSearch").click(function(e){
	    		var json = LG.bulidFilterParams($("#formsearch"));
	        	grid.set('parms', json);
	            //采用原来的请求地址，带上参数加载数据
			  	grid.loadData();
	      	});
		  
	 	   	//重置事件
	      	$("#btnReset").click(function(e){
				grid.set('parms', null);
	            //采用原来的请求地址，带上参数加载数据
			   	grid.loadData();
	     	});
	  	  
	      	//一个重新加载数据方法，该方法主要作为外部框架调用使用
	      	function FF_Reload(){
				grid.loadData();
	      	} 
	      	
		</script>
		
	
					<%-- <td><a
						href="http://localhost:8080/initail-project/moduledemo1/goods/details.do?id=${goods.id }">详情</a>&nbsp;&nbsp;
						<a
						href="http://localhost:8080/initail-project/moduledemo1/goods/delete.do?id=${goods.id }">删除</a>&nbsp;&nbsp;
						<a
						href="http://localhost:8080/initail-project/moduledemo1/charts/toGoodsChart.do?goodsName=${goods.name}">七天销量图</a>&nbsp;&nbsp;
						<a href="http://localhost:8080/initail-project/moduledemo1/customer/addGoodsToCart.do?id=${goods.id}">加入购物车</a>
					</td> --%>
		

</body>
</html>